function customcomplete(complete){
    this.customData.requesting = false;
if(complete)complete();
}
var requesting = false;
function filter({url, data, success, fail, complete, method = "POST"}, islogin = false) {
  console.debug("filter");
    if(requesting)return;
    requesting = true
    setTimeout(function(){
      requesting = false
    },2000)
    request({
      url, data,success, fail, function() {
        console.debug("requesting false");
        requesting = false;
        if (complete)complete();
    }, method},islogin)
}
function request({url, data, success, fail, complete, method = "POST"},islogin=false){
    let Server = "https://heart.ocmcom.com/heart/heart/";  
    var session_id = wx.getStorageSync('PHPSESSID');
        if (session_id != "" && session_id != null) {  
            var header = { 'content-type': 'application/json', 'Cookie': 'PHPSESSID=' + session_id }  
        } else {  
          var header = { 'content-type': 'application/json' }  
        }
        url = Server + url; 
        wx.request({  
            url: url,  
            method: method,  
            data: data,  
            header: header,  
            success: res => {  
              if (session_id == "" || session_id == null||islogin) {  
                wx.setStorageSync('PHPSESSID', res.data.data.PHPSESSION) 
            }  
            let data = res.data  
            res['statusCode'] === 200 ? success(res) : fail(res)  
        },  
        fail: fail,  
        complete: complete
    })  
  
}   
module.exports = request